package com.deryun.tyl.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.deryun.tyl.bean.Policy;
import com.deryun.tyl.bean.Publicity;
import com.deryun.tyl.service.impl.PublicityServiceImpl;

@Controller
@RequestMapping("publicity")
public class PublicityController {

	@Resource(name="publicityServiceImpl")
	private PublicityServiceImpl publicityServiceImpl;
	
	@RequestMapping("/addPublicity")
	public String addPublicity(HttpServletRequest request,Publicity publicity){
		int result = publicityServiceImpl.addPublicity(request,publicity);
		return "redirect:/ftoac/toLoadXxgk";
	}
	
	/***
	 * 获取所有信息公开
	 * @return
	 */
	@RequestMapping("/getAllPublicity")
	public List<Publicity> getAllPublicity(){
		return publicityServiceImpl.getAllPublicity();
	}
	
	/***
	 * 删除指定信息公开
	 * @param id
	 * @return
	 */
	@RequestMapping("/deletePublicity")
	public String deletePublicity(int id){
		publicityServiceImpl.deletePublicity(id);
		return "redirect:/ftoac/toLoadXxgk";
	}
	
	@RequestMapping("/modifyPublicity")
	public String modifyPublicity(Publicity publicity){
		publicityServiceImpl.modifyPublicity(publicity);
		return "redirect:/ftoac/toLoadXxgk";
	}
	
	@RequestMapping("/getPublicityById")
	public String getPublicityById(HttpServletRequest request,int id){
		Publicity message = publicityServiceImpl.getPublicityById(id);
		request.setAttribute("message", message);
		return "success";
	}
	
	@RequestMapping("/setResult")
	public String setResult(Publicity publicity){
		publicityServiceImpl.setResult(publicity);
		return "redirect:/ftoac/toLoadXxgk";
	}
}
